<include file="Public/header"/>
<include file="Public/menu"/>

<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            店铺
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="{:U('Manage/store/index')}"><i class="fa fa-dashboard"></i> 店铺</a></li>
            <li class="active">店铺管理</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content">

        <div class="tab-content">
            <div class="tab-pane active" id="tab_0">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">店铺管理</h3>
                        <div class="form-inline pull-right">
                            <form action="" method="get" pjax-container="">
                                <fieldset>
                                    <select class="form-control" name="search_field" style="height: 30px; font-size: 12px;">
                                        <option value="local_name">门店名称</option>
                                        <option value="local_number">门店编号</option>
                                    </select>
                                    <div class="input-group input-group-sm">
                                        <div class="input-group input-group-sm">
                                            <input type="text" class="form-control" placeholder="" name="search" value="{$search}">
                                        </div>
                                    </div>

                                    <div class="input-group input-group-sm">
                                        <div class="input-group-btn">
                                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i>
                                            </button>
                                        </div>
                                    </div>
                                </fieldset>
                            </form>
                        </div>
                        <div class="btn-group pull-right" style="margin-right: 10px">
                            <a href="/manage/store/storeAdd" class="btn btn-sm btn-success"><i class="fa fa-save"></i>&nbsp;&nbsp;新增</a>
                        </div>

                    </div>
                    <!-- /.box-header -->
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <tbody>
                            <tr>
                                <th></th>
                                <th>ID<a class="fa fa-fw fa-sort" href="{:U('purchase/stores',array('p'=>$p,'order_field'=>'local_id','order'=>$order), '')}"></a></th>
                                <th>门店名称<a class="fa fa-fw fa-sort" href="{:U('purchase/stores',array('p'=>$p,'order_field'=>'local_name','order'=>$order), '')}"></a></th>
                                <th>门店编号<a class="fa fa-fw fa-sort" href="{:U('purchase/stores',array('p'=>$p,'order_field'=>'local_number','order'=>$order), '')}"></a></th>
                                <th>门店类型<a class="fa fa-fw fa-sort" href="{:U('purchase/stores',array('p'=>$p,'order_field'=>'local_type','order'=>$order), '')}"></th>
                                <th>营业状态<a class="fa fa-fw fa-sort" href="{:U('purchase/stores',array('p'=>$p,'order_field'=>'local_status','order'=>$order), '')}"></th>
                                <th>负责人</th>
                                <th>固定电话</th>
                                <th>手机号</th>
                                <th>操作</th>
                            </tr>
                            <volist name="list" id="vo">
                                <tr>
                                    <td></td>
                                    <td>{$vo.local_id}</td>
                                    <td>{$vo.local_name}</td>
                                    <td>{$vo.local_number}</td>
                                    <td>{$vo.local_type_desc}</td>
                                    <td>{$vo.local_status_desc}</td>
                                    <td>{$vo.principal}</td>
                                    <td>{$vo.tel}</td>
                                    <td>{$vo.mobile}</td>
                                    <td>
                                        <a href="{:U('store/storeUpdate', array('local_id'=>$vo['local_id'], ''))}" class="btn btn-sm btn-success grid-refreshe">编辑</a>
                                        <a href="{:U('store/setCommission', array('local_id'=>$vo['local_id'], ''))}" class="btn btn-sm btn-success grid-refreshe">佣金设置</a>
                                        <a href="{:U('store/storeDelete', array('local_id'=>$vo['local_id'], ''))}" class="delete btn btn-warning btn-success grid-refreshe">删除</a>
                                        <a href="{:U('User/index', array('local_id'=>$vo['local_id'], ''))}" class="btn btn-sm btn-success grid-refreshe">会员列表</a>
                                    </td>
                                </tr>
                            </volist>
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <!--<input type="checkbox" class="grid-select-all">&nbsp;&nbsp;&nbsp;-->
                        <a class="btn btn-sm btn-primary grid-refresh"><i class="fa fa-refresh"></i></a>
                        {$page}
                    </div>
                    <!-- /.box-body -->
                </div>
            </div>

        </div>
    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>
<script data-exec-on-popstate>

    $(function () {

        $('.grid-select-all').change(function () {
            if (this.checked) {
                $('.grid-item').prop("checked", true);
            } else {
                $('.grid-item').prop("checked", false);
            }
        });

        $('.batch-delete').on('click',function(e){

            if(!confirm("是否继续")){
                return false;
            }
            var data = [];
            $(".grid-item").each(function (i) {
                if ($(this)[0].checked) {
                    var is_show = true;
                } else {
                    var is_show = false;
                }
                var p_relation_id = $(this).attr('p_relation_id');
                var product_id = $(this).parent().parent().find('td:eq(1)').text();

                data.push({product_id:product_id,p_relation_id:p_relation_id, is_show:is_show});
            });
            if (data) {
                $.ajax({
                    type: "POST",
                    url: "{:U('purchase/save_edit')}",
                    data: {data:data},
                    success: function(msg){
                        if (msg.status) {
                            alert(msg.message);
                        } else {
                            alert(msg.message)
                        }
                        window.location.reload();
                    },
                    error: function (msg) {
                        alert(msg.message);
                    }
                });
            }
        })

    });
</script>

<script src="/Public/layer/layer.js"></script>
<script>
    $(function () {

        $('.delete').click(function () {
            if(!confirm("确定删除？"))
            {
                return false;
            }
        })
    })
</script>
